<!DOCTYPE html>
<html lang="en">
<head>
		<title>SKiDL &mdash; Names, Not Numbers</title>
		<meta charset="utf-8" />
		<link rel="profile" href="http://gmpg.org/xfn/11" />
		<link rel="stylesheet" type="text/css" href="/skidl/theme/css/style.css" />
		<link rel='stylesheet' id='oswald-css'  href='http://fonts.googleapis.com/css?family=Oswald&#038;ver=3.3.2' type='text/css' media='all' />
		<link rel="preconnect" href="https://fonts.googleapis.com">
		<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
		<link href="https://fonts.googleapis.com/css2?family=Oswald&family=Roboto+Condensed&display=swap" rel="stylesheet">
		<!-- <style type="text/css">
			body.custom-background { background-color: #f5f5f5; }
		</style> -->
		<link rel="alternate" type="application/atom+xml"
			title="SKiDL — Flux Atom"
			href="/skidl/" />
		<!--[if lte IE 8]><script src="/skidl/theme/js/html5shiv.js"></script><![endif]-->
</head>

<body class="home blog custom-background " >
	<div id="container">
		<div id="header">
				<h1 id="site-title"><a href="/skidl"><img src="/skidl/images/banner.png" width="100%"></a></h1>
				<!-- <h1 id="site-title"><a href="/skidl">SKiDL</a></h1> -->
		</div><!-- /#banner -->

		<div id="menu">
			<div class="menu-navigation-container">
				<ul id="menu-navigation" class="menu">
						<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="https://github.com/devbisme/skidl">Github</a></li>
						<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="https://github.com/devbisme/skidl/discussions">Forum</a></li>
						<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="/skidl/category/posts.html">Blog</a></li>
						<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="/skidl/api/html/index.html">API</a></li>
						<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="/skidl/">Home</a></li>

				</ul>
			</div> <!--/#menu-navigation-container-->
		</div><!-- /#menu -->

		<div class="page-title">
		</div>

		<div id="contents">

<div class="post type-post status-publish format-standard hentry category-general" id="post">
	<div class="entry-meta">
		<span class="date"><a href="/skidl/names-not-numbers-2017-01-25.html">Wed 25 January 2017</a></span>
		/
		<span class="byline"><a href="/skidl/author/dave-vandenbout.html">Dave Vandenbout</a></span>
	</div> <!-- /#entry-meta -->
	<div class="main">
		<h2 class="entry-title">
			<a href="/skidl/names-not-numbers-2017-01-25.html" title="Permalink to Names, Not Numbers" rel="bookmark">Names, Not Numbers</a>
		</h2>
		<div class="entry-content">
			<p>In my <a href="/skidl/building-a-usb-to-jtag-interface-using-skidl-2017-01-19.html">previous post</a>,
I showed how to use SKiDL to describe the circuit for a simple USB-to-JTAG
interface circuit.
That circuit used a PIC32MX microcontroller in a 28-pin SSOP package:</p>
<p><img alt="PIC32MX in a 28-pin SSOP package." src="images/names-not-numbers/pic32mx-ssop28.png"></p>
<p>and the corresponding SKiDL code was: </p>
<div class="highlight"><pre><span></span><code><span class="n">pic32</span> <span class="o">=</span> <span class="n">Part</span><span class="p">(</span><span class="n">pic32_lib</span><span class="p">,</span> <span class="s1">&#39;pic32MX2\*0F\*\*\*B-SSOP28-SOIC28-SPDIP28&#39;</span><span class="p">,</span>
             <span class="n">footprint</span><span class="o">=</span><span class="s1">&#39;Housings_SSOP:SSOP-28_5.3x10.2mm_Pitch0.65mm&#39;</span><span class="p">)</span>
</code></pre></div>

<p>I wanted to try using the same processor, but housed in a smaller QFN package:</p>
<p><img alt="PIC32MX in a 28-pin QFN package." src="images/names-not-numbers/pic32mx-qfn28.png"></p>
<p>To do that, I changed the SKiDL code to reference a different part and footprint like this:</p>
<div class="highlight"><pre><span></span><code><span class="n">pic32</span> <span class="o">=</span> <span class="n">Part</span><span class="p">(</span><span class="n">pic32_lib</span><span class="p">,</span> <span class="s1">&#39;pic32MX2\*0F\*\*\*B-QFN28&#39;</span><span class="p">,</span>
             <span class="n">footprint</span><span class="o">=</span><span class="s1">&#39;Housings_DFN_QFN:QFN-28-1EP_6x6mm_Pitch0.65mm&#39;</span><span class="p">)</span>
</code></pre></div>

<p>That's it! No other changes were needed because I wrote my SKiDL code to use
pin <em>names</em> instead of pin <em>numbers</em>.
For example, I connected the 12 MHz crystal to the microcontroller <code>OSC1</code> and <code>OSC2</code>
pins like this:</p>
<div class="highlight"><pre><span></span><code><span class="n">pic32</span><span class="p">[</span><span class="s1">&#39;OSC1, OSC2&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">xtal</span><span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>
</code></pre></div>

<p>This works for either version of the microcontroller because they both have
pins named <code>OSC1</code> and <code>OSC2</code>.
But, if I had made the crystal connections for the microcontroller in the 28-pin SSOP
using pin numbers:</p>
<div class="highlight"><pre><span></span><code><span class="n">pic32</span><span class="p">[</span><span class="mi">9</span><span class="p">,</span><span class="mi">10</span><span class="p">]</span> <span class="o">+=</span> <span class="n">xtal</span><span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>  <span class="c1"># OSC1==9, OSC2==10 for 28-pin SSOP version.</span>
</code></pre></div>

<p>then I would have had to change the code when I switched to the QFN packaged version
of the microcontroller:</p>
<div class="highlight"><pre><span></span><code><span class="n">pic32</span><span class="p">[</span><span class="mi">6</span><span class="p">,</span><span class="mi">7</span><span class="p">]</span> <span class="o">+=</span> <span class="n">xtal</span><span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>  <span class="c1"># OSC1==6, OSC2=7 for 28-pin QFN version.</span>
</code></pre></div>

<p>Multiply this by the number of pins a device has (which can be over a thousand
for modern-day parts like FPGAs), and you can see how using pin names
reduces the effort and likelihood of errors when making a
design change.</p>
<p>For the new board, I also changed from using a mini USB connector:</p>
<div class="highlight"><pre><span></span><code><span class="n">usb_conn</span> <span class="o">=</span> <span class="n">Part</span><span class="p">(</span><span class="n">xess_lib</span><span class="p">,</span> <span class="s1">&#39;USBB&#39;</span><span class="p">,</span> <span class="n">footprint</span><span class="o">=</span><span class="s1">&#39;XESS:UX60SC-MB-5ST&#39;</span><span class="p">)</span>
</code></pre></div>

<p>to a micro connector:</p>
<div class="highlight"><pre><span></span><code><span class="n">usb_conn</span> <span class="o">=</span> <span class="n">Part</span><span class="p">(</span><span class="n">xess_lib</span><span class="p">,</span> <span class="s1">&#39;USB-MicroB&#39;</span><span class="p">,</span> <span class="n">footprint</span><span class="o">=</span><span class="s1">&#39;XESS:USB-microB-1&#39;</span><span class="p">)</span>
</code></pre></div>

<p>Once again, using pin names meant I didn't have to touch the rest of the code:</p>
<div class="highlight"><pre><span></span><code><span class="n">usb_conn</span><span class="p">[</span><span class="s1">&#39;D\+, D-, VCC, GND, NC&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">pic32</span><span class="p">[</span><span class="s1">&#39;D\+, D-&#39;</span><span class="p">],</span> <span class="n">vusb</span><span class="p">,</span> <span class="n">gnd</span><span class="p">,</span> <span class="n">NC</span>
</code></pre></div>

<p>After the changes to the SKiDL script were done, I just ran it and imported the
netlist into KiCad's <code>PCBNEW</code> layout program.
At that point, it didn't matter whether I used pin names or numbers: I still had
to re-route the wire traces on the PCB because the physical location
of the pins had changed. There's no getting around that.</p>
<p><img alt="Completed USB-to-JTAG board layout." src="images/names-not-numbers/pcbnew-routed.png"></p>
<p>Here's a side-by-side of the previous and new USB-to-JTAG boards:</p>
<p><img alt="Old and new USB-to-JTAG boards." src="images/names-not-numbers/old-and-new-boards.jpg"></p>
		</div> <!--/#entry-content-->
	</div> <!--/#main-->
</div>  <!--/#post-->

		</div>

		<div id="footer">
			<p> </p>
		</div><!-- /#footer -->
	</div><!-- /#container -->
	<div style="display:none"></div>
</body>
</html>